#include "Storage/StorageFactory.hpp"
#include <cassert>

namespace Storage
{

StorageBase* StorageFactory::getStorage( Model::CaseEntity& entity) const
{
	assert( this->hasStorageRegistered( typeid( entity)));
	return storages_.find( typeid( entity).name())->second;
}

// ---------------------------------------------------------------------------------------------------------------------

void StorageFactory::registerStorage( const type_info& caseEntityID, StorageBase* pStorage )
{
	assert( storages_.end() == storages_.find( caseEntityID.name()));
	assert( NULL != pStorage);
	storages_.insert( std::make_pair( caseEntityID.name(), pStorage));
}

// ---------------------------------------------------------------------------------------------------------------------

bool StorageFactory::hasStorageRegistered( const type_info& caseEntityID ) const
{
	return ( storages_.end() != storages_.find( caseEntityID.name()));
}

} // namespace Storage
